package com.yc.cloud.portal.controller;

import com.yc.cloud.basic.api.CommonPage;
import com.yc.cloud.basic.api.ResponseResult;
import com.yc.cloud.basic.dto.BaseQueryParam;
import com.yc.cloud.portal.service.SceneService;
import com.yc.cloud.portal.vo.SceneVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.val;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * 场景
 *
 * @author Yancy
 * @date 2024-03-28
 */
@RestController
@RequestMapping("/scene")
@Api(value = "场景", tags = "场景接口")
public class SceneController {

    @Resource
    private SceneService sceneService;


    @GetMapping
    @ApiOperation(value = "场景列表", notes = "支持分页查询,字段模糊匹配,排序等")
    public ResponseResult<CommonPage<SceneVo>> list(BaseQueryParam param) {
        val result = sceneService.list(param);
        return ResponseResult.success(CommonPage.restPage(result));
    }


    @GetMapping("{id}")
    @ApiOperation(value = "场景详情", notes = "根据ID查询")
    public ResponseResult<SceneVo> get(@PathVariable @ApiParam(value = "ID", required = true) Long id) {
        val result = sceneService.get(id);
        return ResponseResult.success(sceneService.convertVo(result));
    }

//    @GetMapping("{id}/test")
//    @ApiOperation(value = "场景详情-test", notes = "根据ID查询")
//    public ResponseResult<SceneVo> test(@PathVariable @ApiParam(value = "ID", required = true) Long id) {
//        sceneService.test(id);
//        return ResponseResult.success();
//    }

}
